*/
/* This module is for the holux (gm-100) .wpo format */
-#include "defs.h"
+#include <cstring> // for strncpy, memset, strcpy, strlen
+#include <cstdio> // for sprintf
+#include <ctime> // for gmtime, mktime, time_t, tm
+
+#include <QDate> // for QDate
+#include <QString> // for QString
+#include <QTime> // for QTime
+#include <QtGlobal> // for qRound
+
+#include "defs.h" // for Waypoint, le_write16, le_write32
#include "holux.h"
-//#include <math.h>
-#include <cstdio>
-#include <cstdlib>
+#include "gbfile.h" // for gbfclose, gbfopen_le, gbfile, gbfread
+#include "src/core/datetime.h" // for DateTime
-static gbfile* file_in, *file_out;
-static unsigned char* HxWFile;
-static short_handle mkshort_handle;
+
+static gbfile* file_in;
+static gbfile* file_out;
+static unsigned char* HxWFile;
+static short_handle mkshort_handle;
#define MYNAME "Holux"
static const char* mknshort(const char* stIn,unsigned int sLen)
{
-#define MAX_STRINGLEN 255
+ constexpr int MAX_STRINGLEN = 255;
static char strOut[MAX_STRINGLEN];
char strTmp[MAX_STRINGLEN];
setshort_length(mkshort_handle, sLen);
setshort_mustuniq(mkshort_handle, 0);
+ setshort_defname(mkshort_handle, "");
char* shortstr = mkshort(mkshort_handle, stIn, false);
strcpy(strTmp,shortstr);
double lon = wpt->longitude * 36000.0;
double lat = wpt->latitude * -36000.0;
-
- /* round it to increase the accuracy */
- if (lon != 0) {
- lon += (double)((int)lon/abs((int)lon)) * .5;
- }
- if (lat != 0) {
- lat += (double)((int)lat/abs((int)lat)) * .5;
- }
-
short sIndex = le_read16(&((WPTHDR*)HxWFile)->num);
if (sIndex >= MAXWPT) {
// yield undefined results for negative values.
// We intentionally convert to int, then do an implicit
// conversion to unsigned in the call.
- le_write32(&pWptHxTmp->pt.iLatitude,(signed int) lat);
- le_write32(&pWptHxTmp->pt.iLongitude,(signed int) lon);
+ le_write32(&pWptHxTmp->pt.iLatitude, qRound(lat));
+ le_write32(&pWptHxTmp->pt.iLongitude, qRound(lon));
pWptHxTmp->checked = 01;
pWptHxTmp->vocidx = (short)0xffff;
le_write16(&((WPTHDR*)HxWFile)->num, ++sIndex);